﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Classes.actions {
    import Classes.*;
    import com.greensock.*;

    public class ActionTween extends NPCAction {

        public static const TO:int = 0;
        public static const FROM:int = 1;

        protected var m_tweenType:int;
        protected var m_duration:Number;
        protected var m_vars:Object;
        protected var m_onComplete:Function;

        public function ActionTween(_arg1:NPC, _arg2:int, _arg3:Number, _arg4:Object){
            super(_arg1);
            this.m_tweenType = _arg2;
            this.m_duration = _arg3;
            this.m_vars = _arg4;
            if (this.m_vars["onComplete"]){
                this.m_onComplete = this.m_vars.onComplete;
            } else {
                this.m_onComplete = null;
            };
            this.m_vars.onComplete = this.onTweenComplete;
        }
        override public function enter():void{
            super.enter();
            this.startTween();
        }
        override public function reenter():void{
            super.reenter();
            this.startTween();
        }
        protected function startTween():void{
            switch (this.m_tweenType){
                case TO:
                    TweenLite.to(m_npc, this.m_duration, this.m_vars);
                    break;
                case FROM:
                    TweenLite.from(m_npc, this.m_duration, this.m_vars);
                    break;
            };
        }
        protected function onTweenComplete():void{
            if (this.m_onComplete != null){
                this.m_onComplete.apply();
            };
            m_npc.getStateMachine().removeState(this);
        }
        override public function getInterrupt():int{
            return (NO_INTERRUPT);
        }

    }
}//package Classes.actions 
